package com.ymatou.iapi.productquery.testcase.old20210113;

import com.shop2cn.iapi.agentproducts.parameter.AddAgentProductBean;
import com.ymatou.iapi.productquery.parameter.GetProductSharePicBean;
import com.ymatou.iapi.productquery.service.GetProductSharePicCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.AddAgentProductCallService;
import com.ymttest.database.model.YmtAgentWxCodePic;
import com.ymttest.database.sqlwapper.YmtAgentWxCodePicWapper;
import com.ymttest.utils.AgentUsers;
import org.junit.*;
import org.junit.experimental.categories.Category;

import java.util.List;

/**
 * 查询商品分享图Test FreeMaker Template自动生成代码
 */
@TestSuite
@Ignore
public class Ts_GetProductSharePic {
	private static GetProductSharePicBean getproductsharepicBean;
	private static GetProductSharePicCall getproductsharepicCall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("查询商品分享图Test");
	}

	@Before
	public void caseUp() {
		getproductsharepicBean = new GetProductSharePicBean();
		getproductsharepicCall = new GetProductSharePicCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getproductsharepicCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	// vip渠道
	private static int vipRootUserId = AgentUsers.vipRootUserId;
	private static String vipRootUserName = "NickautoTest";

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductSharePic_001() {
		Logger.start(true, "正确数据，成功");
		try {
			int sellerId=500849412;
			String productId="p4062829";
			YmtAgentWxCodePicWapper ymtAgentWxCodePicWapper = new YmtAgentWxCodePicWapper();
			List<YmtAgentWxCodePic> selectBySellerIdAndProductId = ymtAgentWxCodePicWapper.selectBySellerIdAndProductId(sellerId, productId);
			getproductsharepicBean.setSellerId(sellerId);
			getproductsharepicBean.setProductId(productId);
			getproductsharepicCall.setData(getproductsharepicBean);
			getproductsharepicCall.callService();
			Logger.verifyEquals("200", getproductsharepicCall.getString("Code"), "验证code");
			Logger.verifyEquals(selectBySellerIdAndProductId.get(0).getPicUrl(), getproductsharepicCall.getJsonObject().getAsJsonObject("Data").get("picUrl").getAsString(), "验证PidUrl");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductSharePic_002() {
		Logger.start(true, "正确数据，成功");
		try {
			int sellerId=500849412;
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			Thread.sleep(5000);
			YmtAgentWxCodePicWapper ymtAgentWxCodePicWapper = new YmtAgentWxCodePicWapper();
			List<YmtAgentWxCodePic> selectBySellerIdAndProductId = ymtAgentWxCodePicWapper.selectBySellerIdAndProductId(sellerId, productId);
			getproductsharepicBean.setSellerId(sellerId);
			getproductsharepicBean.setProductId(productId);
			getproductsharepicCall.setData(getproductsharepicBean);
			getproductsharepicCall.callService();
			Logger.verifyEquals("200", getproductsharepicCall.getString("Code"), "验证code");
			Logger.verifyEquals(selectBySellerIdAndProductId.get(0).getPicUrl(), getproductsharepicCall.getJsonObject().getAsJsonObject("Data").get("picUrl").getAsString(), "验证PidUrl");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
}